<?php
class ControllerReportSaleCoupon extends AdminController {
	public function index() {

		$this->document->setTitle($this->_['heading_title']);

		$qf = new Query_filter();

		M('report/coupon');

		$this->data['coupons'] = array();

		$coupon_total = $this->model_report_coupon->getTotalCoupons($qf);

		$results = $this->model_report_coupon->getCoupons($qf);

		foreach ($results as $result) {
			$this->data['coupons'][] = array(
				'name'   => $result['name'],
				'code'   => $result['code'],
				'orders' => $result['orders'],
				'total'  => $this->currency->format($result['total'], C('config_currency')),
			);
		}

		$this->data['pagination'] = $this->pagination($coupon_total)->render();

		$this->data['filter_date_start'] = $qf->get('filter_date_start');
		$this->data['filter_date_end'] = $qf->get('filter_date_end');

		$this->display('report/sale_coupon.tpl');
	}
}
?>